package h0910;
/**
  * @description 反转二叉树
  * @author 不知名帅哥
  * @date 2024/9/10 21:09
  * @version 1.0
*/
public class ReverseBinaryTree {
    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }
    public static void main(String[] args) {

    }
    public TreeNode invertTree(TreeNode root) {
        if (root==null){
            return null;
        }
        TreeNode left=invertTree(root.left);
        root.left= invertTree(root.right);
        root.right=left;
        return root;
    }
}
